# coding: utf-8
#SHA-256

import hashlib

def cal_sha256(value):
    '''
    sha256计算
    return:加密结果转成16进制字符串形式，并大写
    '''
    sha = hashlib.sha256()
    sha.update(value.encode("utf-8"))
    return sha.hexdigest().upper()

#计算文件的SHA256
def cal_file_sha256(filename):
    with open(filename, "r") as f:
        sha = hashlib.sha256()
        sha.update(f.read().encode("utf-8"))
        return sha.hexdigest().upper()